﻿using Mes.Domain.BoundedContext.Entities.Quality;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mes.Infrastructure.Data.BoundedContext.EntityTypeConfigurations.Quality
{
    public class CharacteristicEntityConfig : IEntityTypeConfiguration<Characteristic>
    {
        public void Configure(EntityTypeBuilder<Characteristic> builder)
        {
            builder.ToTable("characteristic");
            builder.HasKey(b => b.Char_Id);
            builder.Property(b => b.Char_Name).IsRequired().HasMaxLength(40);
            builder.Property(b => b.Char_Desc).HasMaxLength(80);
            builder.Property(b => b.Type).IsRequired();
            builder.Property(b => b.Uom_Id).IsRequired();
            builder.Property(b => b.Severity_Cd).IsRequired();
            builder.Property(b => b.Default_Chart).IsRequired();
            builder.Property(b => b.Automated_Coll).IsRequired();
            builder.Property(b => b.Time_Interval);
            builder.Property(b => b.Time_Int_Unit);
            builder.Property(b => b.Num_Decimals).IsRequired();
            builder.Property(b => b.Sample_Size_Source);
            builder.Property(b => b.Normal_Sample_Size).IsRequired();
            builder.Property(b => b.Minimum_Sample_Size).IsRequired();
            builder.Property(b => b.Maximum_Sample_Size);
            builder.Property(b => b.Num_Defect_Opp);
            builder.Property(b => b.Mov_Avg_Span);
            builder.Property(b => b.Sigma_Est);
            builder.Property(b => b.Trend_Limits).IsRequired();
            builder.Property(b => b.Use_Std_Err).IsRequired();
            builder.Property(b => b.Cl_Source);
            builder.Property(b => b.Samples_For_Cl);
            builder.Property(b => b.Samples_Before_Cl).IsRequired();
            builder.Property(b => b.Std_Avg);
            builder.Property(b => b.Std_Avg_Is_Target).IsRequired();
            builder.Property(b => b.Std_Deviation);
            builder.Property(b => b.Cl_Xbar);
            builder.Property(b => b.Lcl_Xbar);
            builder.Property(b => b.Ucl_Xbar);
            builder.Property(b => b.Cl_Range);
            builder.Property(b => b.Lcl_Range);
            builder.Property(b => b.Ucl_Range);
            builder.Property(b => b.Cl_Sigma);
            builder.Property(b => b.Lcl_Sigma);
            builder.Property(b => b.Ucl_Sigma);
            builder.Property(b => b.Cl_Ix);
            builder.Property(b => b.Lcl_Ix);
            builder.Property(b => b.Ucl_Ix);
            builder.Property(b => b.Cl_Imr);
            builder.Property(b => b.Lcl_Imr);
            builder.Property(b => b.Ucl_Imr);
            builder.Property(b => b.Cl_Ma);
            builder.Property(b => b.Lcl_Ma);
            builder.Property(b => b.Ucl_Ma);
            builder.Property(b => b.Cl_Mr);
            builder.Property(b => b.Lcl_Mr);
            builder.Property(b => b.Ucl_Mr);
            builder.Property(b => b.Cl_Ms);
            builder.Property(b => b.Lcl_Ms);
            builder.Property(b => b.Ucl_Ms);
            builder.Property(b => b.Cl_P);
            builder.Property(b => b.Lcl_P);
            builder.Property(b => b.Ucl_P);
            builder.Property(b => b.Cl_Np);
            builder.Property(b => b.Lcl_Np);
            builder.Property(b => b.Ucl_Np);
            builder.Property(b => b.Cl_C);
            builder.Property(b => b.Lcl_C);
            builder.Property(b => b.Ucl_C);
            builder.Property(b => b.Cl_U);
            builder.Property(b => b.Lcl_U);
            builder.Property(b => b.Ucl_U);
            builder.Property(b => b.Fit_Test);
            builder.Property(b => b.Hist_Capability_Sigma);
            builder.Property(b => b.Filter_By_Ent_Id).IsRequired();
            builder.Property(b => b.Filter_By_Item_Id).IsRequired();
            builder.Property(b => b.Filter_By_Wo_Id).IsRequired();
            builder.Property(b => b.Filter_By_Oper_Id).IsRequired();
            builder.Property(b => b.Filter_By_Process_Id).IsRequired();
            builder.Property(b => b.Filter_By_Segment_Req_Id).IsRequired();
            builder.Property(b => b.Filter_By_Segment_Resp_Id).IsRequired();
            builder.Property(b => b.Filter_By_Spare1).IsRequired();
            builder.Property(b => b.Filter_By_Spare2).IsRequired();
            builder.Property(b => b.Filter_By_Spare3).IsRequired();
            builder.Property(b => b.Filter_By_Spare4).IsRequired();
            builder.Property(b => b.Spare1).HasMaxLength(80);
            builder.Property(b => b.Spare2).HasMaxLength(80);
            builder.Property(b => b.Spare3).HasMaxLength(80);
            builder.Property(b => b.Spare4).HasMaxLength(80);
            builder.Property(b => b.Last_Edit_Comment).HasMaxLength(254);
            builder.Property(b => b.Last_Edit_By).IsRequired().HasMaxLength(40);
            builder.Property(b => b.Last_Edit_At).IsRequired();
            builder.Property(b => b.Char_Id).IsRequired().UseIdentityColumn().HasIdentityOptions(startValue: 0, incrementBy: 1, minValue: 0);
        }
    }
}
